from django.views import View
# 导入返回响应
from SaaSDevelTool.data_return_response import create_response
# 导入错误信息装饰器
from SaaSDevelTool.data_return_response import error_message_detection
# 获取数据库连接
from SaaSDevelTool.data_mysql_data import db

"""
用户权限禁用
"""


class SaaSDevelLoginModelDelete(View):
    @error_message_detection
    def post(self, request):
        # 获取用户编号
        login_id = int(request.POST.get("login_id"))

        if login_id:
            # 进行删除
            delete_sum_login_table_sql = """
                DELETE FROM 
                    db_saas_center.sum_login_table 
                WHERE 
                    login_id = '{}'
                ;""".format(login_id)
            # 执行语句
            db.update(delete_sum_login_table_sql)
            # 返回响应
            return create_response(code=200, msg="用户信息删除成功。")

        # 返回异常
        else:
            return create_response(code=400, msg="请求参数传递错误。")

